/* eslint-disable no-undef,no-unused-vars,spaced-comment */
/* 这里不实用vue-cookie的原因是实验如何项目 混用jq 和 jq插件*/
import cookie from 'jquery.cookie';

require('expose-loader?$!jquery');

class Utils {
  static isLocalStorageSupported() {
    try {
      if (!window.localStorage || !window.sessionStorage) {
        return false;
      }
      localStorage.setItem('storage_test', 1);
      localStorage.removeItem('storage_test');
      return true;
    } catch (e) {
      return false;
    }
  };

  static GetLocalData(key) {
    if (this.isLocalStorageSupported()) {
      return localStorage.getItem(key);
    } else {
      return $.cookie(key);
    }
  }

  static SetLocalData(key, value) {
    if (this.isLocalStorageSupported()) {
      return localStorage.setItem(key, value);
    } else {
      return $.cookie(key, value);
    }
  }

  static RemoveLocalData(key) {
    if (this.isLocalStorageSupported()) {
      return localStorage.removeItem(key);
    } else {
      return $.removeCookie(key);
    }
  };
};

export {Utils};
